﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace GraphViewer
{
    static class StringExtensions
    {
        public static bool IsNumeric(this string text)
        {
            return text.All(Char.IsNumber);
        }

        public static string RemoveAccents(this string text)
        {
            string s = text.Normalize(NormalizationForm.FormD);

            StringBuilder sb = new StringBuilder();

            for (int k = 0; k < s.Length; k++)
            {
                UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(s[k]);

                if (uc != UnicodeCategory.NonSpacingMark)
                {
                    sb.Append(s[k]);
                }
            }

            return sb.ToString();
        }
    }
}
